package com.flying.acls.domain.service;

import com.flying.acls.domain.context.ExpressionContext;
import com.flying.acls.model.PermsExpr;
import com.flying.acls.model.PermsExpr;
import com.flying.acls.model.ResExpr;
import com.flying.acls.model.SidExpr;
import com.flying.acls.model.SidExpr;

/**
 * Strategy interface for three key object matching.
 * <p>
 * <p>Used by {@link com.flying.acls.domain.service.AclService,
 * <p>
 * <p>The default implementation is {@link AntStyleMatcher}, supporting the
 * Ant-style pattern syntax for string. but for integer, we are using bit operator.
 * <p>The interface is the key for extending the function. You could implement yours
 * as your wish.
 */

public interface Matcher {
    /**
     * match method for Resource
     *
     * @param context the expression context.
     * @param config  the config resource.
     * @param access  the accessing resource.
     * @return {@code true} if it matched, {@code false} if it didn't
     */
    boolean match(ExpressionContext context, ResExpr config, ResExpr access);

    /**
     * match method for Sid
     *
     * @param context the expression context.
     * @param config  the config Sid.
     * @param access  the accessing Sid.
     * @return {@code true} if it matched, {@code false} if it didn't
     */
    boolean match(ExpressionContext context, SidExpr config, SidExpr access);

    /**
     * match method for Permission
     *
     * @param context the expression context.
     * @param config  the config Permission.
     * @param access  the accessing Permission.
     * @return {@code true} if it matched, {@code false} if it didn't
     */
    boolean match(ExpressionContext context, PermsExpr config, PermsExpr access);
}
